package com.koron.order.patrol.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.bean.scheduleShift.ScheduleShift;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.patrol.bean.po.PatrolPo;
import com.koron.order.patrol.bean.query.PatrolQuery;
import com.koron.order.patrol.service.PatrolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 巡视工单-基础信息(Patrol)表控制层
 *
 * @author zhouj
 * @since 2021-10-26 15:32:40
 */
@Api(tags = "巡视工单-基础信息(Patrol)")
@RestController
@RequestMapping("/patrol/baseInfo/")
public class PatrolController {

    @Autowired
    private PatrolService patrolService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改巡视工单-基础信息")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody PatrolPo patrol) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "insertOrUpdate", Integer.class, patrol));
    }

    @ApiOperation(value = "新增巡视工单-基础信息")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody PatrolPo patrol) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "insert", Integer.class, patrol));
    }

    @ApiOperation(value = "批量新增巡视工单-基础信息")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<PatrolPo> patrolList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "insertBatch", Integer.class, patrolList));
    }

    @ApiOperation(value = "根据id更新巡视工单-基础信息")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody PatrolPo patrol) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "update", Integer.class, patrol));
    }

    @ApiOperation(value = "根据id删除巡视工单-基础信息")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询巡视工单-基础信息")
    @GetMapping("queryById")
    public Response<PatrolPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "queryById", PatrolPo.class, id));
    }

    @ApiOperation(value = "不分页查询巡视工单-基础信息列表")
    @GetMapping("queryList")
    public Response<List> queryList(PatrolQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "queryList", List.class, query));
    }

    @ApiOperation(value = "分页查询巡视工单-基础信息列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(PatrolQuery query, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "queryPageList", PageInfo.class, query, pageQuery));
    }

    @ApiOperation(value = "根据条件更新巡视工单-巡视人员信息")
    @PostMapping("updatePatrolStaff")
    public Response<Integer> updatePatrolStaff(@RequestBody ScheduleShift scheduleShift) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "updatePatrolStaff", Integer.class, scheduleShift));
    }

    @ApiOperation(value = "根据日期统计巡视工单信息")
    @GetMapping("staPatrolInfo")
    public Response<List> staPatrolInfo(String patrolDeptId, String startTime, String endTime) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolService, "staPatrolInfo", List.class, patrolDeptId, startTime, endTime));
    }

}
